/**
 * 基础菜单 dubbo 服务
 */
<template>
  <div>
    <!-- 面包屑导航 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>dubbo 服务</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 搜索筛选 -->
    <el-form :inline="true" :model="formInline" class="user-search">
      <el-form-item label="搜索：">
        <el-input size="small" v-model="requestData.applicationName" placeholder="应用名称"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button size="small" type="primary" icon="el-icon-search" @click="search">搜索</el-button>

      </el-form-item>
    </el-form>
    <!--列表-->
    <el-table size="small" :data="listData" highlight-current-row v-loading="loading" border element-loading-text="拼命加载中" style="width: 100%;">
      <el-table-column sortable prop="id" label="服务id" width="300">
      </el-table-column>
      <el-table-column sortable prop="applicationName" label="应用名称" width="300">
      </el-table-column>
      <el-table-column sortable prop="serviceName" label="服务名称" width="300">
      </el-table-column>
      <el-table-column sortable prop="version" label="服务版本" width="300">
      </el-table-column>
      <el-table-column align="center" label="操作" min-width="300">
        <template slot-scope="scope">
          <el-button size="mini"  @click="toDetail(scope.row)">测试</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页组件 -->
    <Pagination v-bind:child-msg="pageparm" @callFather="callFather"></Pagination>

  </div>
</template>

<script>
import { deptList, deptSave, deptDelete } from '../../api/userMG'
import Pagination from '../../components/Pagination'
import {GetDubboPage} from "../../api/basisMG";

export default {
  data() {
    return {
      nshow: true, //switch开启
      fshow: false, //switch关闭
      loading: false, //是显示加载
      editFormVisible: false, //控制编辑页面显示与隐藏
      title: '添加',
      editForm: {
        deptId: '',
        deptName: '',
        deptNo: '',
        token: localStorage.getItem('logintoken')
      },
      // rules表单验证
      rules: {
        deptName: [
          { required: true, message: '请输入部门名称', trigger: 'blur' }
        ],
        deptNo: [{ required: true, message: '请输入部门代码', trigger: 'blur' }]
      },
      formInline: {
        requestService:'com.qiall.oms.ability.FindDubboService',
        requestMethod:'findBuddoServiceByPage',
        serviceGroup:null,
        version:'1.0.0',
        requestData:''
      },
      requestData: {
        applicationName: null,
        pageQuery: {
          pageSize: 10,
          pageNum: 1
        }
      },
      userparm: [], //搜索权限
      listData: [], //用户数据
      // 分页参数
      pageparm: {
        currentPage: 1,
        pageSize: 10,
        total: 10
      }
    }
  },
  // 注册组件
  components: {
    Pagination
  },
  /**
   * 数据发生改变
   */

  /**
   * 创建完毕
   */
  created() {
    this.getdata(this.formInline)
  },

  /**
   * 里面的方法只有被调用才会执行
   */
  methods: {
    // 获取公司列表
    getdata(parameter) {
      this.loading = true
      // 模拟数据开始
      this.formInline.requestData=JSON.stringify([this.requestData]);
      let _this=this
      GetDubboPage(this.formInline).then(data=>{
        _this.listData = data.body.responseData.body.dataList
        _this.pageparm.currentPage = this.formInline.page
        _this.pageparm.pageSize = this.formInline.limit
        _this.pageparm.total =data.body.responseData.body.total
      })
      this.loading = false
    },
    // 分页插件事件
    callFather(parm) {
      this.requestData.pageQuery.pageNum = parm.currentPage
      this.requestData.pageQuery.pageSize = parm.pageSize
      this.formInline.requestData=JSON.stringify([this.requestData]);
      this.getdata(this.formInline)
    },
    // 搜索事件
    search() {
      this.getdata(this.formInline)
    },
    toDetail(data){
      console.log(data)
      this.$router.push({path:'/service/Service',query: {data:JSON.stringify(data)}})
    }
  }

}
</script>

<style scoped>
.user-search {
  margin-top: 20px;
}
.userRole {
  width: 100%;
}
</style>


